<template>
    <div class="Box">
        <div class="imgBox">
            <img :src="props.pic" @click="goVideo"/>
            <span>{{ Number.isInteger(props.length)?voideoAllTime(props.length):formatStrVideoTime(props.length) }}</span>
        </div>
        <div class="infoBox">
            <p @click="goVideo">{{ props.title }}</p>
            <p class="videoInfo">
                <img src="@/assets/videoIcon/playBlack.png"/>
                <span>{{ formatNum(props.play) }}</span>
                <span>{{ formatIsYMD(props.created) }}</span>
            </p>
        </div>
    </div> 
</template>

<script lang="ts" setup>
import { formatNum,formatIsYMD,voideoAllTime,formatStrVideoTime } from '@/utils/format'
import { useRouter } from 'vue-router'
interface Props{
    bvid:string
    aid:number           //avid
    mid:number          
    created:number      //创建时间
    title:string        //标题
    play:number          //播放量
    length:string | number      //时长
    pic:string
}
const props = defineProps<Props>()
const router = useRouter()

function goVideo(){
    let routeData = router.resolve({path:'/video',query:{'avid':props.aid,'bvid':props.bvid,'cid':props.mid}})
    window.open(routeData.href, '_blank');
}
</script>

<style lang="scss" scoped>
p{
    padding: 0;
    margin: 0;
}
.Box{
    display: flex;
    flex-direction: column;
    justify-content: start;
    align-items: start;
    height: 100%;
    width: 100%;
    gap: 10px;
}
.imgBox{
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
    height: calc(100% - 65px);
    & img:nth-child(1){
        width: 100%;
        height: 100%;
        border-radius: 4px;
        cursor: pointer;
    }
    & span:last-child{
        position: absolute;
        background: rgb(0, 0, 0,0.4);
        color: white;
        right: 0;
        bottom: 0;
        font-size: 12px;
        padding: 1px 5px;
        border-radius: 4px; 
    }
}
.infoBox{
    box-sizing: border-box;
    width: 100%;
    height: 55px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    & p:nth-child(1){
        line-height: 17px;
        font-size: 13px;
        color: #18191C;
        @include tweLineShow;
        height: 34px;
        text-align: left;
        cursor: pointer;
    }
    & p:nth-child(1):hover{
        color:#409EFF;
    }
    
}
.videoInfo{
    display: flex;
    justify-content: start;
    align-items: center;
    gap: 3px;
    line-height: 16px;
    color: #9499A0;
    & img{
        margin-right: 2px;
        width: 14px;
        height: 14px;
    }
    & span{
        font-size: 12px;
        white-space: nowrap;
    }
    & span:last-child{
        margin-left: 20px;
    }
}
</style>